//
//  YMPDFFonts.m
//  TestDemo
//
//  Created by fantasy on 16/6/26.
//  Copyright © 2016年 goappbox. All rights reserved.
//

#import "YMPDFFonts.h"

//static void
//parseFont(const char *key, CGPDFObjectRef object, void *info)
//{
//    bool isEmbedded;
//    const char *name;
//    VoyeurFont *font;
//    NSMutableDictionary *fonts;
//    CGPDFDictionaryRef dict, descriptor;
//    NSString *baseFont, *fontType, *encoding;
//
//    fonts = info;
//
//    if (!CGPDFObjectGetValue(object, kCGPDFObjectTypeDictionary, &dict))
//        return;
//
//    baseFont = @"<< none >>";
//    if (CGPDFDictionaryGetName(dict, "BaseFont", &name))
//        baseFont = [NSString stringWithUTF8String:name];
//    fontType = @"<< unknown >>";
//    if (CGPDFDictionaryGetName(dict, "Subtype", &name))
//        fontType = [NSString stringWithUTF8String: name];
//
//    isEmbedded = false;
//    if (CGPDFDictionaryGetDictionary(dict, "FontDescriptor", &descriptor)) {
//        if (CGPDFDictionaryGetObject(descriptor, "FontFile", &object)
//            || CGPDFDictionaryGetObject(descriptor, "FontFile2", &object)
//            || CGPDFDictionaryGetObject(descriptor, "FontFile3", &object)) {
//            isEmbedded = true;
//        }
//    }
//
//    encoding = @"<< font-specific >>";
//    if (CGPDFDictionaryGetName(dict, "Encoding", &name))
//        encoding = [NSString stringWithUTF8String:name];
//
//    font = [[VoyeurFont alloc] initWithBaseFont:baseFont type:fontType
//                                       encoding:encoding isEmbedded:isEmbedded];
//    [fonts setObject:font forKey:baseFont];
//    [font release];
//}

@interface YMPDFFonts ()

@end

@implementation YMPDFFonts

- (void)appliedToPDFObject:(CGPDFObjectRef)object forKey:(NSString *)key {
    CGPDFDictionaryRef dict;
    if (!CGPDFObjectGetValue(object, kCGPDFObjectTypeDictionary, &dict))
    {
        return;
    }
    
    self[key] = key;
}

@end
